package com.sanjiahantang.youjiaclient.module.me.order.models.impl;

import android.content.Context;

import com.sanjiahantang.youjiaclient.base.BaseBean;
import com.sanjiahantang.youjiaclient.base.BaseView;
import com.sanjiahantang.youjiaclient.base.CallBack;
import com.sanjiahantang.youjiaclient.config.ConfigValue;
import com.sanjiahantang.youjiaclient.http.BaseDelegate;
import com.sanjiahantang.youjiaclient.http.OkHttpClientManager;
import com.sanjiahantang.youjiaclient.module.common.beans.StringBean;
import com.sanjiahantang.youjiaclient.module.me.address.beans.AddressBean;
import com.sanjiahantang.youjiaclient.module.me.order.beans.CreateServiceOrderResponseBean;
import com.sanjiahantang.youjiaclient.module.me.order.beans.LogisticsBean;
import com.sanjiahantang.youjiaclient.module.me.order.beans.OrderResponseBean;
import com.sanjiahantang.youjiaclient.module.me.order.beans.RequireOrderBean;
import com.sanjiahantang.youjiaclient.module.me.order.beans.Service3PartBean;
import com.sanjiahantang.youjiaclient.module.me.order.beans.ServiceListBean;
import com.sanjiahantang.youjiaclient.module.me.order.beans.ShopListBean;
import com.sanjiahantang.youjiaclient.module.me.order.models.IOrderModel;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by zy on 2017/10/25.
 */

public class OrderModel implements IOrderModel {

    @Override
    public void searchPriceDesignPhoneForRole(final Context context, Map<String, String> param, final CallBack<RequireOrderBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/project/phone/plan/searchPriceDesignPhoneForCustomer",
                param,new BaseDelegate.ResultCallback<RequireOrderBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(RequireOrderBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void servieceOrdeList(final Context context, Map<String, Object> param, final CallBack<ServiceListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/findOrderSQLForServicePhone",
                param,new BaseDelegate.ResultCallback<ServiceListBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ServiceListBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });

    }

    @Override
    public void searchUserAddressOrder(final Context context, Map<String, String> params, final CallBack<AddressBean> callBack) {

        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/customerAddress/searchUserAddressOrder",
                params,new BaseDelegate.ResultCallback<AddressBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(AddressBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void createOrderForMallCommon(final Context context, Object param, final CallBack<OrderResponseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderForMallCommon",
                param,new BaseDelegate.ResultCallback<OrderResponseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(OrderResponseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void payGoodsOrderPhone(final Context context, Object requestBean, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/payGoodsOrderPhone",
                requestBean,new BaseDelegate.ResultCallback<BaseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void loadOrderList(final Context context, Map<String, Object> params, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/findOrderSQLForGoodsPhone", params,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });


    }

    @Override
    public void createOrderForDesign(final Context context, Map<String, Object> param, final CallBack<CreateServiceOrderResponseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderForDesign", param,
                new BaseDelegate.ResultCallback<CreateServiceOrderResponseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(CreateServiceOrderResponseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void cancelOrderPhone(final Context context, Map<String, Object> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/cancelOrderPhone", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void operatorState(final Context context, Map<String, Object> param, final CallBack<BaseBean> callBack,String orderCode) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/operatorState", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                },orderCode);
    }

    @Override
    public void searchGoodsRaForCode(final Context context, Map<String, Object> param, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderForMallCommon", param,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void payServiceOrderPhone(final Context context, Object bean, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/payServiceOrderPhone",
                bean,new BaseDelegate.ResultCallback<BaseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void searchServiceRaForCode(final Context context, Map<String, Object> param, final CallBack<Service3PartBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderForDesign",
                param,new BaseDelegate.ResultCallback<Service3PartBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(Service3PartBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void searchGoodsRaForCodeForPlan(final Context context, Map<String, Object> param, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/createOrderForMallCommonForPlan", param,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void searchServiceOrder(final Context context, Map<String, String> param, final CallBack<ServiceListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/searchServiceRaForCode", param,
                new BaseDelegate.ResultCallback<ServiceListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ServiceListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void findOrderGoodsForOrderCode(final Context context, Map<String, String> param, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/order/goods/findOrderGoodsForOrderCode", param,
                new BaseDelegate.ResultCallback<StringBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StringBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void saveInvoiceInfoPhoneForCustomer(final Context context, Map<String, Object> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/invoice/saveInvoiceInfoPhoneForCustomer", param,
                new BaseDelegate.ResultCallback<BaseBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void findOrderExpressInfo(final Context context, Map<String, Object> param, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/express/findOrderExpressInfo", param,
                new BaseDelegate.ResultCallback<StringBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StringBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void getCheckCodeGoods(final Context context, Object param, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/getCheckCodeGoods", param,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void getCheckCodeService(final Context context, Object param, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/getCheckCodeService", param,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void saveBankPayGoods(final Context context, Object param, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/saveBankPayGoods", param,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }

    @Override
    public void saveBankPayService(final Context context, Object param, final CallBack<ShopListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/order/phone/saveBankPayService", param,
                new BaseDelegate.ResultCallback<ShopListBean>() {
                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(ShopListBean response, Object tag) {
                        callBack.onSuccess(response,context,tag);
                    }
                });
    }
}
